//新闻查询
var floor;
$(function () {
    $.ajax({
        url:"easybuy/selectNews",
        dataType:"json",
        data:{
            pageNow:1,
            pageSize:5
        },
        success:function (data) {
            var $ul=$(".inews ul");
            for(i=0;i<data.length;i++){
                var $li=$("<li>" +
                    "<span>[公告]</span>" +
                    "<a href='Member_News_Show.html?id="+data[i].id+"'>" +
                    data[i].title +
                    "</a>" +
                    "</li>")
                $ul.append($li);
            }
        }
    })
})
function show(id) {
    floor=floor-1;
    //console.log(Cargorys);
    $.ajax({
        url:"easybuy/indexProducts",
        type:"post",
        async:false,
        data:{
            id:id
        },
        dataType:"json",
        success:function (data) {
            var categoryL2="<span class=\"i_mores fr\">";
            for (var i in data.categoryL2) {
                categoryL2=categoryL2+"<a href='BrandList.html?id="+data.categoryL2[i].id+"'>"+data.categoryL2[i].name+"</a>&nbsp; &nbsp; &nbsp; ";
            }
            categoryL2=categoryL2+"</span>"
            var $div1=$("<div class=\"i_t mar_10\">" +
                "<span class=\"floor_num\">"+floor+"F</span>" +
                "<span class=\"fl\">"+data.categoryL1.name+"</span>" +
                categoryL2 +
                "</div>")
            var categoryL3="<div class=\"fresh_txt_c\">"
            for (var i in data.categoryL3) {
                categoryL3=categoryL3+"<a href='BrandList.html?id="+data.categoryL3[i].id+"'>"+data.categoryL3[i].name+"</a>";
            }
            categoryL3=categoryL3+"</div>"
            var products="";
            for (var i in data.productList) {
                products=products+"<li>" +
                    "<div class='name'><a href='Product.html?id="+data.productList[i].id+"'>"+data.productList[i].name+"</a></div>" +
                    "<div class=\"price\">" +
                    "<font>￥<span>"+data.productList[i].price+"</span></font> &nbsp;库存："+data.productList[i].stock+
                    "</div>" +
                    "<div class=\"img\"><a href='Product.html?id="+data.productList[i].id+"'><img src=\"images/"+data.productList[i].fileName+"\" width=\"185\" height=\"155\" /></a></div>"+
                    "</li>"
            }
            var $div2=$("<div class=\"content\">\n" +
                "    \t<div class=\"fresh_left\">\n" +
                "        \t<div class=\"fre_ban\">\n" +
                "            \t<div id=\"imgPlay1\">\n" +
                "                    <ul class=\"imgs\" id=\"actor1\">\n" +
                "                        <li><a href=\"#\"><img src=\"images/fre_r.jpg\" width=\"211\" height=\"286\" /></a></li>\n" +
                "                        <li><a href=\"#\"><img src=\"images/fre_r.jpg\" width=\"211\" height=\"286\" /></a></li>\n" +
                "                        <li><a href=\"#\"><img src=\"images/fre_r.jpg\" width=\"211\" height=\"286\" /></a></li>\n" +
                "                    </ul>\n" +
                "                    <div class=\"prevf\">上一张</div>\n" +
                "                    <div class=\"nextf\">下一张</div> \n" +
                "                </div>   \n" +
                "            </div>\n" +
                "            <div class=\"fresh_txt\">\n" +
                "            \t<div class=\"fresh_txt_c\">\n" +
                "                \t"+categoryL3+"\n" +
                "                </div>\n" +
                "            </div>\n" +
                "        </div>\n" +
                "        <div class=\"fresh_mid\">\n" +
                "        \t<ul>\n" +
                "            \t"+products+"\n" +
                "            </ul>\n" +
                "        </div>\n" +
                "        <div class=\"fresh_right\">\n" +
                "        \t<ul>\n" +
                "            \t<li><a href=\"#\"><img src=\"images/fre_b1.jpg\" width=\"260\" height=\"220\" /></a></li>\n" +
                "                <li><a href=\"#\"><img src=\"images/fre_b2.jpg\" width=\"260\" height=\"220\" /></a></li>\n" +
                "            </ul>\n" +
                "        </div>\n" +
                "    </div>    ")
            $("[class='content mar_20']").first().after($div1);
            $($div1).after($div2);
        }
    })
}
$(function () {
    floor=7;
    show(681);
    show(676);
    show(670);
    show(660);
    show(628);
    show(548);
})
